
function changeClassButtonAdd(element){
	if(element.getAttribute('class') == "add_funtion"){
		element.setAttribute('class','add_funtion_mousedown');
	} else{
		element.setAttribute('class','add_funtion');
	}
}
var currentTable = "";
function getTableInfo(){
	currentTable = document.frmMenu.tables.value;
    var table = document.getElementById(currentTable);
    if(table == null){
        var jxGetTableInfo = new Jx();
        jxGetTableInfo.setParameter('tableName',currentTable);
        jxGetTableInfo.success('recieveTableInfo');
        jxGetTableInfo.request("/generate/querybuilder/gettableinfo","");
    }
}
function recieveTableInfo(){
	var info = new Array();
	info['tableName'] = currentTable;
	info['listCol'] = listCol;
	var i = listCol.length;
	var height = i*20+5;
	info['height'] = height;
	templateFactory.setData(info);
	templateFactory.setTemplate('TEMPLATE-ROOT');
	var newTable = templateFactory.getListParameter();
	
	var designZone = document.getElementById('QueryBuilder-Body');
	var divTable = document.createElement('div');
	divTable.setAttribute('id',currentTable);
	divTable.setAttribute('class','QB_Table');
	divTable.setAttribute('draggable','true');
	divTable.setAttribute('style','position:absolute;left: 60px; top: 633px; display: block;');
	divTable.innerHTML = newTable;
	designZone.appendChild(divTable);
	
	enableDaD(currentTable);
}
function selectCol(elemt){
	var color = elemt.style.color;
	if(color == "red"){
		elemt.style.color = "black";
	}else{
		elemt.style.color = "red";
	}
}
var table = null;
function deleteTable(id){
	var zone = document.getElementById('QueryBuilder-Body');
	var olddiv = document.getElementById(id);
	zone.removeChild(olddiv);
}
function enableDaD(tableName){
	  table = document.getElementById(tableName);
      table.addEventListener('dragstart', handleDragStart, false);
      table.addEventListener('dragenter', handleDragEnter, false)
      table.addEventListener('dragover', handleDragOver, false);
      table.addEventListener('dragleave', handleDragLeave, false);
      //table.addEventListener('drop', handleDrop, false);
      //table.addEventListener('dragend', handleDragEnd, false);
    
    var desktop = document.getElementById('desktop');
      //desktop.addEventListener('dragstart', handleDragStartDeskTop, false);
      desktop.addEventListener('dragenter', handleDragEnterDeskTop, false)
      desktop.addEventListener('dragover', handleDragOverDeskTop, false);
      desktop.addEventListener('dragleave', handleDragLeaveDeskTop, false);
      desktop.addEventListener('drop', handleDropDeskTop, false);
      desktop.addEventListener('dragend', handleDragEndDeskTop, false);
}



